﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using VitCode.Castle.DataAccess;

namespace AMS.Web.Report
{
    public static class ReportQueryHelp
    {
        private static readonly CastleAccess m_Acc = new CastleAccess();
        private static string sql = @"select count(*) from  dbo.AmsWorkBill_WoCommand cmd join dbo.AmsCore_AssetInfo ai  
                               on ai.Id = cmd.AssetInfoId join dbo.AmsWorkBill_WoInfo wo on cmd.WoCode=wo.Code ";
        public static string GetTotalCount()
        {
            string totalCount = "";
            string sqlString = "select count(*) from dbo.AmsWorkBill_WoCommand cmd join dbo.AmsCore_AssetInfo ai  on ai.Id = cmd.AssetInfoId";
            var dt = m_Acc.GetDataTableBySql(sqlString);
            if(dt != null && dt.Rows.Count > 0)
            {
                totalCount = dt.Rows[0][0].ToString();
            }
            return totalCount;
        }

        public static string GetCountByTypeName(string typename)
        {
            string count = "";
            string sqlString = "";
            sqlString = sql +  " where wo.TypeName='" + typename + "'";
            var dt = m_Acc.GetDataTableBySql(sqlString);
             if (dt != null && dt.Rows.Count > 0)
             {
                 count = dt.Rows[0][0].ToString();
             }
            return count;
        }
    }
}
